package cn.jwm.org.controller;


import cn.jwm.org.domain.Employee;
import cn.jwm.org.service.IEmployeeService;
import cn.jwm.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/employee")
public class EmployeeController {

    @Autowired
    private IEmployeeService employeeService;


    @GetMapping
    public AjaxResult getAll(){
        try {
            // 调用EmployeeService
            List<Employee> employees = employeeService.getAll();
            return AjaxResult.me().setDataObj(employees);
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.me().setSuccess(false).setMessage("员工查询失败!"+e.getMessage());
        }
    }

}
